home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / sys / epoll.h < prev    next >
Encoding:
C/C++ Source or Header  |  2008-11-14  |  4.0 KB  |  129 lines

  1. /* Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
  2.    This file is part of the GNU C Library.
  3.  
  4.    The GNU C Library is free software; you can redistribute it and/or
  5.    modify it under the terms of the GNU Lesser General Public
  6.    License as published by the Free Software Foundation; either
  7.    version 2.1 of the License, or (at your option) any later version.
  8.  
  9.    The GNU C Library is distributed in the hope that it will be useful,
  10.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  12.    Lesser General Public License for more details.
  13.  
  14.    You should have received a copy of the GNU Lesser General Public
  15.    License along with the GNU C Library; if not, write to the Free
  16.    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  17.    02111-1307 USA.  */
  18.  
  19. #ifndef    _SYS_EPOLL_H
  20. #define    _SYS_EPOLL_H    1
  21.  
  22. #include <stdint.h>
  23. #include <sys/types.h>
  24.  
  25. /* Get __sigset_t.  */
  26. #include <bits/sigset.h>
  27.  
  28. #ifndef __sigset_t_defined
  29. # define __sigset_t_defined
  30. typedef __sigset_t sigset_t;
  31. #endif
  32.  
  33.  
  34. enum EPOLL_EVENTS
  35.   {
  36.     EPOLLIN = 0x001,
  37. #define EPOLLIN EPOLLIN
  38.     EPOLLPRI = 0x002,
  39. #define EPOLLPRI EPOLLPRI
  40.     EPOLLOUT = 0x004,
  41. #define EPOLLOUT EPOLLOUT
  42.     EPOLLRDNORM = 0x040,
  43. #define EPOLLRDNORM EPOLLRDNORM
  44.     EPOLLRDBAND = 0x080,
  45. #define EPOLLRDBAND EPOLLRDBAND
  46.     EPOLLWRNORM = 0x100,
  47. #define EPOLLWRNORM EPOLLWRNORM
  48.     EPOLLWRBAND = 0x200,
  49. #define EPOLLWRBAND EPOLLWRBAND
  50.     EPOLLMSG = 0x400,
  51. #define EPOLLMSG EPOLLMSG
  52.     EPOLLERR = 0x008,
  53. #define EPOLLERR EPOLLERR
  54.     EPOLLHUP = 0x010,
  55. #define EPOLLHUP EPOLLHUP
  56.     EPOLLONESHOT = (1 << 30),
  57. #define EPOLLONESHOT EPOLLONESHOT
  58.     EPOLLET = (1 << 31)
  59. #define EPOLLET EPOLLET
  60.   };
  61.  
  62.  
  63. /* Valid opcodes ( "op" parameter ) to issue to epoll_ctl().  */
  64. #define EPOLL_CTL_ADD 1    /* Add a file decriptor to the interface.  */
  65. #define EPOLL_CTL_DEL 2    /* Remove a file decriptor from the interface.  */
  66. #define EPOLL_CTL_MOD 3    /* Change file decriptor epoll_event structure.  */
  67.  
  68.  
  69. typedef union epoll_data
  70. {
  71.   void *ptr;
  72.   int fd;
  73.   uint32_t u32;
  74.   uint64_t u64;
  75. } epoll_data_t;
  76.  
  77. struct epoll_event
  78. {
  79.   uint32_t events;    /* Epoll events */
  80.   epoll_data_t data;    /* User data variable */
  81. };
  82.  
  83.  
  84. __BEGIN_DECLS
  85.  
  86. /* Creates an epoll instance.  Returns an fd for the new instance.
  87.    The "size" parameter is a hint specifying the number of file
  88.    descriptors to be associated with the new instance.  The fd
  89.    returned by epoll_create() should be closed with close().  */
  90. extern int epoll_create (int __size) __THROW;
  91.  
  92.  
  93. /* Manipulate an epoll instance "epfd". Returns 0 in case of success,
  94.    -1 in case of error ( the "errno" variable will contain the
  95.    specific error code ) The "op" parameter is one of the EPOLL_CTL_*
  96.    constants defined above. The "fd" parameter is the target of the
  97.    operation. The "event" parameter describes which events the caller
  98.    is interested in and any associated user data.  */
  99. extern int epoll_ctl (int __epfd, int __op, int __fd,
  100.               struct epoll_event *__event) __THROW;
  101.  
  102.  
  103. /* Wait for events on an epoll instance "epfd". Returns the number of
  104.    triggered events returned in "events" buffer. Or -1 in case of
  105.    error with the "errno" variable set to the specific error code. The
  106.    "events" parameter is a buffer that will contain triggered
  107.    events. The "maxevents" is the maximum number of events to be
  108.    returned ( usually size of "events" ). The "timeout" parameter
  109.    specifies the maximum wait time in milliseconds (-1 == infinite).
  110.  
  111.    This function is a cancellation point and therefore not marked with
  112.    __THROW.  */
  113. extern int epoll_wait (int __epfd, struct epoll_event *__events,
  114.                int __maxevents, int __timeout);
  115.  
  116.  
  117. /* Same as epoll_wait, but the thread's signal mask is temporarily
  118.    and atomically replaced with the one provided as parameter.
  119.  
  120.    This function is a cancellation point and therefore not marked with
  121.    __THROW.  */
  122. extern int epoll_pwait (int __epfd, struct epoll_event *__events,
  123.             int __maxevents, int __timeout,
  124.             __const __sigset_t *__ss);
  125.  
  126. __END_DECLS
  127.  
  128. #endif /* sys/epoll.h */
  129.